	//隐藏月份
var hiddenday = new Date();    
var d,x,temp = "";
var diyprice=0;
var diy=1;
var sdate="";
var pakage=0;
var d = new Date();
//变更日期需存入隐藏变量中，在上下月调整中使用
window.hiddenday = d;    
//	initday(d);
function initday(day){
	var d1 = new Date(day.getFullYear(),day.getMonth(),1);
	var d2 = new Date(day.getFullYear(),day.getMonth()+1,0);
	var firstday = new Date(day.getFullYear(),day.getMonth(),1).getDay();
	//当前年
    var year = d2.getFullYear();   
    $("#theyear").html(year);  
    //当前月份  
	var month = parseInt(d2.getMonth())+1;    
	month = month < 10 ? '0' + month:month;
	//日期从1计数	
    var countDay = 1;   
		
		//整月有多少天             
		var dayofmonth = d2.getDate();    
		
		temp="";
		for(i=0;i<firstday;i++){
			temp+="<div class=\"day\"><div class=\"dayin\"></div></div>"
		};
	
		var arr = new Array();
		//将日期载入arr
		for(;countDay <= dayofmonth;countDay++){
			arr.push(year + "-" + month + "-" + (countDay<10 ? '0' + countDay : countDay));
		};  
		//拼接显示  
		for(a in arr){
			temp += "<div class=\"day\" id=\"a"+ arr[a] +"\"><div class=\"dayin\">"+ arr[a].substring(5) +"</div><div class=\"dayst\">已满</div></div>"
		};   
		//将数据放入div中 
		$("#da2").html(temp);
		temp = null;
		
		//给每个日期绑定click事件
		var dayClick = $(".day");
		for(var i=0; i<dayClick.length; i++){
			var oClick = dayClick[i];
			$(oClick).click(function(){
				var oID = $(this).attr("id");
				//获取该日期是否排档
				if(oID && $(this).attr("ok")){
					//已排档
				    //	alert('已排档');

					var da = $(this).attr("id").substring(1);
					//$(this).removeAttr("ok");
					//$(this).removeAttr("style");
					//$("#addData > [value="+ da +"]").remove();
					
                    $(this).css("background","#ff8000");
                   // $(this).css("color","#ffffff");
                    
                    var odSelect = $("#delData");
					var odDay = $(this).contents().html();
					var deloDay = "<option value="+ odDay +">"+ odDay +"</option>";
                    
                    if(inmain==0){
                         sdate=year+"-"+odDay;
                        location.href="mobile.php?act=module&name=shopping3&do=wlsearch&weid=1&sdate="+sdate;
                        return;
                    }
                                        
					odSelect.append(deloDay);  
                    sdate=year+"-"+odDay;
                    $("#choosedate").val(year+"-"+odDay);                  
                    $(".mModal").hide();
                    $(".mDialog").hide();
                    $(".mDialog").html("");    
                    
                                
				}else{
					//添加排档
                    /*
					if(!$(this).attr("ok") && !$(this).attr("no")){
						$(this).css("background","#92FF97");
						$(this).attr("no","no");
                        
                        
                        
						var oSelect = $("#addData");
						var oDay = $(this).contents().html();
						var addoDay = "<option value="+ oDay +">"+ oDay +"</option>";
						oSelect.append(addoDay);
                        
                        $("#delData > [value="+ oDay +"]").remove();
					}else{
						//取消排档
						var da = $(this).attr("id").substring(1);
						$(this).removeAttr("no");
						$(this).removeAttr("style");
						$("#addData > [value="+ da +"]").remove();
						
					};*/
					
				};
                setdate();
			});
		};
		
		//已排档的日期
		var okData = $("#okData option");
		for(var i=0; i<okData.length; i++){
			var aDay = okData[i].innerHTML;
			var redDay = "a" + aDay;
			$("#" + redDay).css("background","#c9a063");
            $("#" + redDay).css("color","#ffffff");
            $("#" + redDay+" .dayst").html("可选");
            
			$("#" + redDay).attr('ok','ok');
		};
		
	}
	

	function setdate(){
		var okData2 = $("#addData option");
        var s2="";
		for(var i=0; i<okData2.length; i++){
		  
          s2=s2+","+okData2[i].innerHTML;
        }
        $("#addDatalist").val(s2);
		var s3="";
        var okData3 = $("#delData option");
		for(var i=0; i<okData3.length; i++){
		  s3=s3+","+okData3[i].innerHTML;
        }       
        
        $("#delDatalist").val(s3);
	}
function showImgDetail(thi){
       // if(){
            
       // }
        MLoading.show('加载中');
        var params = {
        }

        var _tmpHtml ='<div style="text-align:center;padding-left: 0.5rem;"><p class="dwwl">';
        _tmpHtml =_tmpHtml+'<span style="height: 20px;font-size:0.8rem" id="shangyue"><<上 月 </span> &nbsp;&nbsp;<span id="theyear" style="font-size:0.8rem"></span>&nbsp;&nbsp;  <span   style="height: 20px;font-size:0.8rem" id="xiayue">下 月>> </span></p>';
        _tmpHtml =_tmpHtml+'<div id="da"><div class="xingqi"><ul style="margin:auto;">';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周日</li>';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周一</li>';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周二</li>';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周三</li>';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周四</li>';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周五</li>';
        _tmpHtml =_tmpHtml+'<li style="width:13%;">周六</li></ul></div>';
        _tmpHtml =_tmpHtml+'<div class="cls"></div>';
        _tmpHtml =_tmpHtml+'<div id="da2"></div></div></div>';
        MDialog.popupCustom(_tmpHtml,true,true);
        
        
        initday(d);
        MLoading.hide();
	//下个月
	$("#shangyue").click(function(){
		hiddenday = new Date(hiddenday.getFullYear(),hiddenday.getMonth()-1,1);
		initday(hiddenday);
	});
	//上个月
	$("#xiayue").click(function(){
		hiddenday = new Date(hiddenday.getFullYear(),hiddenday.getMonth()+1,1);
		initday(hiddenday);
	});
    }    